import $ from "jquery";
import oldcom from "../utils/oldcommon/common";
require("../utils/remove_ad");
require("../utils/oldcommon/example");
require("../utils/oldcommon/layer");
import "../../scss/login.scss";

import com from "../utils/common";

$(function () {
    //登录注册js
    let user = {
        login: function () {
            //手机号码验证
            let mobile = $.trim($("#mobile").val());
            let password = $.trim($("#password").val());
            if (com.CheckMobile(mobile)) {

            } else {
                oldcom.alert("手机号码格式不正确。");
                return;
            }
            if (password.length < 6) {
                oldcom.alert("密码至少6位。");
                return;
            }

            com.ajax({
                url: "/user/login",
                data: {
                    Mobile: mobile,
                    Password: password
                },
                method: "post",
                ok: function (data) {
                    console.log(data);
                    $('.mask').click(function(){
                        window.location.href = './user_page/user_center.html';
                    })
                    layer.open({
                        content: '登录成功。'
                        , btn: '确定'
                        , yes: function () {
                            setTimeout(function () {
                                window.location.href = './user_page/user_center.html';
                            }, 1000);
                        }
                    });
                },
                fail: function (data) {
                    console.log(data);
                }
            });
        }
    };

    $(".express_login").click(function () {
        user.login();
    });
});
